
public class MultiSender {
	private int numSenders;
	private int receiverStartPort;
	private String traceFile;
	private String logDir;
	private int trafficShaperPort;

	public MultiSender(int numSenders, int trafficShaperPort,
			int receiverStartPort, String traceFile, String logDir) {
		this.numSenders = numSenders;
		this.trafficShaperPort = trafficShaperPort;
		this.receiverStartPort = receiverStartPort;
		this.traceFile = traceFile;
		this.logDir = logDir;
	}

	public void start() throws Exception {
		for (int i = 1; i <= numSenders; i++) {
			String logFile = logDir + "senderLog" + i + ".txt";
			int receiverPortNumber = receiverStartPort + (i-1);
			Sender sender = new Sender(trafficShaperPort, receiverPortNumber,
					traceFile, logFile);
			sender.start();
		}
	}

	public static void main(String[] args) throws Exception {
		if (args.length != 5) {
			System.err.println("Usage: java MultiSender numSenders trafficShaperPort receiverStartPort traceFile logDir");
			return;
		}

		int numSenders = Integer.parseInt(args[0]);
		int trafficShaperPort = Integer.parseInt(args[1]);
		int receiverStartPort = Integer.parseInt(args[2]);
		String traceFile = args[3];
		String logDir = args[4];
		if( !(logDir.endsWith("/") || logDir.endsWith("\\")) )
		{
			System.err.println("Please provide a trailing slash for logDir");
			return;
		}
		
		MultiSender multiSender = new MultiSender(numSenders,
				trafficShaperPort, receiverStartPort, traceFile, logDir);
		multiSender.start();
	}
}
